#!/bin/zsh
# only zsh supports floating point arithmetics

cost=1000000
to_pay=1000000
paid=0
yr=0
while [ $yr -lt 20 ] ; do
	paid=$(( $paid + $cost * 0.05 + $to_pay * 0.02 ))
	: $(( to_pay -= cost * 0.05 ))
	: $(( yr += 1 ))
	printf "год %2d: заплатил %11.2f $ за дом стоимостью %i $\tto_pay=%11.2f $\n" $yr $paid $cost $to_pay
done
printf "\nпереплата %2.2f%%\n" $((paid / cost * 100 - 100))
